package member;

import java.io.Reader;
import java.sql.Timestamp;
import java.util.List;
import java.util.ArrayList;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.opensymphony.xwork2.ActionSupport;

public class memberdeleteAction extends ActionSupport{
	
	public static Reader reader;
	public static SqlMapClient sqlMapper;
	
	private Memberbean param;
	private Memberbean result;
	
	private String m_id;
	private String m_pw;
	private int deletechk;
	
	public memberdeleteAction() throws Exception{
		reader = Resources.getResourceAsReader("sqlMapConfig.xml");
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
		reader.close();
	}
	public String form() throws Exception{
		return SUCCESS;
	}
	
	public String execute() throws Exception{
		param = new Memberbean();
		result = new Memberbean();
		
		param.setM_id(getM_id());
		param.setM_pw(getM_pw());
		
		System.out.println(m_id);
		System.out.println(m_pw);
		
		result = (Memberbean) sqlMapper.queryForObject("getMember", getM_id());
		
		if(result.getM_pw().equals(m_pw)){
			deletechk = 1;
			sqlMapper.update("deleteMember", param);
		}else{
			deletechk = -1;
		}

		return SUCCESS;

	}
	public Memberbean getParam() {
		return param;
	}
	public void setParam(Memberbean param) {
		this.param = param;
	}
	public Memberbean getResult() {
		return result;
	}
	public void setResult(Memberbean result) {
		this.result = result;
	}
	public String getM_id() {
		return m_id;
	}
	public void setM_id(String m_id) {
		this.m_id = m_id;
	}
	public String getM_pw() {
		return m_pw;
	}
	public void setM_pw(String m_pw) {
		this.m_pw = m_pw;
	}
	public int getDeletechk() {
		return deletechk;
	}
	public void setDeletechk(int deletechk) {
		this.deletechk = deletechk;
	}
}